/*
 * Powered By XY
 * Since 2020
 */

package com.xy.biz.base.service.impl;

import java.util.Collection;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.xy.lang.domain.Result;
import com.xy.biz.base.domain.bo.SupplierBO;
import com.xy.biz.base.domain.query.SupplierQuery;
import com.xy.biz.base.service.SupplierService;
import com.xy.biz.base.manager.SupplierManager;

/**
 * 
 * 
 * @author zgy
 * @date 2021-9-22
 */
@Service
public class SupplierServiceImpl implements SupplierService {

	@Autowired
	private SupplierManager supplierManager;
	
	@Override
	public Result<?> saveSupplier(SupplierBO supplierBO) {
		int affectedRows = supplierManager.saveSupplier(supplierBO);
		if (affectedRows > 0) {
			return Result.success();
		}
		return Result.ofErrorRowsAffected();
	}
	
	@Override
	public Result<?> saveAllSupplier(Collection<SupplierBO> collection) {
		int affectedRows = supplierManager.saveAllSupplier(collection);
		if (affectedRows > 0) {
			return Result.success();
		}
		return Result.ofErrorRowsAffected();
	}
	
	@Override
	public Result<?> updateSupplier(SupplierBO supplierBO) {
		int affectedRows = supplierManager.updateSupplier(supplierBO);
		if (affectedRows > 0) {
			return Result.success();
		}
		return Result.ofErrorRowsAffected();
	}
	
	@Override
	public Result<?> deleteSupplier(Long supplierId) {
		int affectedRows = supplierManager.deleteSupplier(supplierId);
		if (affectedRows > 0) {
			return Result.success();
		}
		return Result.ofErrorRowsAffected();
	}
	
	@Override
	public SupplierBO getSupplier(Long supplierId) {
		return supplierManager.getSupplier(supplierId);
	}
	
	@Override
	public List<SupplierBO> listSupplierById(Collection<Long> collection) {
		return supplierManager.listSupplierById(collection);
	}
	
	@Override
	public List<SupplierBO> listSupplier(SupplierQuery query) {
		return supplierManager.listSupplier(query);
	}
	
	@Override
	public int countSupplier(SupplierQuery query) {
		return supplierManager.countSupplier(query);
	}
	
}
